#include <stdio.h>

int main(int argc, char *argv[])
{
	int year,month,day,run,ping,d,week;
	scanf("%d%d%d",&year,&month,&day);
	run=(year-1-1900)/4;
	ping=year-1900-(year-1-1900)/4;
	
	if(year%4==0&&year%100||year%400==0){
		switch(month){
			case 1:if(day<=31){
				d=0;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 2:if(day<=29){
				d=31;
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 3:if(day<=31){
				d=60;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 4:if(day<=30){
				d=91;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 5:if(day<=31){
				d=121;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 6:if(day<=30){
				d=152;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 7:if(day<=31){
				d=182;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 8:if(day<=31){
				d=213;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 9:if(day<=30){
				d=244;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 10:if(day<=31){
				d=274;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 11:if(day<=30){
				d=305;
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 12:if(day<=31){
				d=336;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			default:printf("month is error.\n");

		}
		
	}
	else{
		switch(month){
			case 1:if(day<=31){
				d=0;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 2:if(day<=28){
				d=31;
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 3:if(day<=31){
				d=59;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 4:if(day<=30){
				d=90;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 5:if(day<=31){
				d=120;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 6:if(day<=30){
				d=151;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 7:if(day<=31){
				d=181;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 8:if(day<=31){
				d=212;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 9:if(day<=30){
				d=243;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 10:if(day<=31){
				d=273;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 11:if(day<=30){
				d=304;
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			case 12:if(day<=31){
				d=335;	
				day=day+d+run*366+ping*365;
				week=day%7;
				printf("%d\n",week);
			}
				else printf("day is error.\n");
				break;
			default:printf("month is error.\n");
		}
	}
	
}